- Introduction to Bayesian inference
- The
BayesFactorpackage - \(t\)-Test
- ANOVA
- Linear model setup
BayesFactor packageExample from Rouder, Haaf, & Aust (2018)
generalTestBF, lmBFregressionBF, lmBFcorrelationBFttestBFmeta.ttestBFanovaBF, lmBFcontingencyTableBFproportionBFgeneralTestBF, lmBFregressionBF, lmBFcorrelationBFttestBFmeta.ttestBFanovaBF, lmBFcontingencyTableBFproportionBFCan be used to test our position 1 .
Equation setup
BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study)
Obtain strong evidence by increasing model discriminability.
Stefan, Gronau, Schönbrodt, & Wagenmakers (2019)
BayesFactor package in R and JASP use default priors for the t-test called JZS prior.BayesFactor package in R and JASP use default priors for the t-test called JZS prior.BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study
, rscale = 1 / sqrt(2))
BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study
, rscale = 1 / sqrt(2))
par(mar = c(3,3,.5,.5), mgp = c(2,.7,0))
x <- seq(-3, 3, .01)
y <- dcauchy(x, 0, 1/sqrt(2))
plot(x, y, type = "l", lwd = 2
, ylab = "Density", xlab = "Effect Size"
, col = "darkblue", ylim = c(0, .5))
lines(x, dnorm(x), col = adjustcolor(1, .5), lty = 2, lwd = 2)
abline(v = c(-1, 0, 1), lwd = 0.5, col = adjustcolor(1, alpha.f = 0.3))
## 0% 25% 50% 75% 100% ## -755409.12 -1.24 -0.01 1.21 109714.01
BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study
, rscale = 1 / 4)
Put your setting in the zoom chat!
BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study
, rscale = 1 / 2)
The plight of refugees generates an empathic response which results in an increase in favorability for conservative and liberals alike.
est.attitude <- BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study, rscale = 1 / 2
, posterior = T, iterations = 20000)
plot(est.attitude[,"beta (Neutral - Refugee plight)"])
The plight of refugees generates an empathic response which results in an increase in favorability for conservative and liberals alike.
BayesFactor.BayesFactor.BayesFactor::ttestBF(formula = attitude ~ story
, data = immigration_study
, rscale = 1 / 2
, nullInterval = c(-Inf, 0))
## Bayes factor analysis ## -------------- ## [1] Alt., r=0.5 -Inf<d<0 : 4.196947 ±0% ## [2] Alt., r=0.5 !(-Inf<d<0) : 0.08881904 ±0% ## ## Against denominator: ## Null, mu1-mu2 = 0 ## --- ## Bayes factor type: BFindepSample, JZS
SourceURL <- "https://raw.githubusercontent.com/PerceptionCognitionLab/data0/master /contexteffects/FlankerStroopSimon/cleaning.R" devtools::source_url(SourceURL)
library(tidyverse) stroop.agg <- stroop %>% group_by(ID, congruency) %>% summarize(mrt = mean(RT)) %>% spread(congruency, mrt)
Cook, J., & Lewandowsky, S. (2016). Rational irrationality: Modeling climate change belief polarization using Bayesian networks. Topics in Cognitive Science, 8(1), 160–179. Retrieved from https://dx.doi.org/10.1111/tops.12186
Rouder, J. N., Haaf, J. M., & Aust, F. (2018). From theories to models to predictions: A Bayesian model comparison approach. Communication Monographs, 85, 41–56. Retrieved from https://doi.org/10.1080/03637751.2017.1394581
Rouder, J. N., & Morey, R. D. (2012). Default Bayes factors for model selection in regression. Multivariate Behavioral Research, 47, 877–903. Retrieved from http://dx.doi.org/10.1080/00273171.2012.734737
Rouder, J. N., Morey, R. D., Speckman, P. L., & Province, J. M. (2012). Default Bayes factors for ANOVA designs. Journal of Mathematical Psychology, 56, 356–374. Retrieved from http://dx.doi.org/10.1016/j.jmp.2012.08.001
Rouder, J. N., Speckman, P. L., Sun, D., Morey, R. D., & Iverson, G. (2009). Bayesian \(t\)-tests for accepting and rejecting the null hypothesis. Psychonomic Bulletin and Review, 16, 225–237. Retrieved from http://dx.doi.org/10.3758/PBR.16.2.225
Stefan, A. M., Gronau, Q. F., Schönbrodt, F. D., & Wagenmakers, E.-J. (2019). A tutorial on Bayes Factor Design Analysis using an informed prior. Behavior Research Methods, 51(3), 1042–1058. doi:10.3758/s13428-018-01189-8
Tversky, A., & Kahneman, D. (1974). Judgment under uncertainty: Heuristics and biases. Science, 185(4157), 1124–1131. Retrieved from https://doi.org/10.1126/science.185.4157.1124